#include "binarySearchTree.h"

enum {
    end,insert,delete
};

int main() {
    pBinarySearchTree binarySearchTree = makeTree();
    int tmp = 0;
    while(1){
        scanf("%d",&tmp);
        if(tmp==-1) break;
        insertNode_int(binarySearchTree,tmp);
    };
    inOrderVisitTree(binarySearchTree);

    while(tmp!=end){
        printf("请输入要执行的操作：0.退出 1.插入节点 2.删除节点\n");
        scanf("%d",&tmp);
        switch (tmp) {
            case end:{
                break;
            }
            case insert:{
                printf("输入节点值：");
                scanf("%d",&tmp);
                insertNode_int(binarySearchTree,tmp);
                break;
            }
            case delete:{
                printf("输入节点值：");
                scanf("%d",&tmp);
                removeNode(binarySearchTree,tmp,NULL);
                break;
            }
        }
        printf("当前二叉排序树状态如下：\n");
        inOrderVisitTree(binarySearchTree);
    }
    destroyTree(binarySearchTree);
}
